package com.i2863.tools.weixinmp.util;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created by xuweiwei on 2017/8/16.
 */
public class QiniuManager {

    public static AtomicInteger automicInteger = new AtomicInteger();

    private static List<QiniuUpload> qiniuUploadList = new ArrayList<QiniuUpload>();

    static{
        //千域互联
        QiniuUpload qiniuUpload = new QiniuUpload("LplD_2KC-o7-3omKyCTgXjnHgPUITUFm6F0ck-T0","ENZvx9UweRe8ekH1po7ffovDiapDqZS8UltW9wal","images-bucket","imageccsobey.i2863.com");

        //城阳
        QiniuUpload chengyang = new QiniuUpload("-6X153kpLHP8GEf9MSfXA4DftVyBiBCRbTNlvkzb","l5Dv-Nx3KQ4f1WPDKbgKENBZFiM0_LwYq8OvINh1","bucket56","vod.56.i2863.com");
        //金堂

        //垦利
        //三水

        qiniuUploadList.add(qiniuUpload);



    }

    public static QiniuUpload get(){
        return qiniuUploadList.get(automicInteger.getAndAdd(1)%qiniuUploadList.size());
    }



    public static void main(String[] args) {
        for(int i=1;i<10;i++) {
            final int j = i;
            new Thread(new Runnable() {
                @Override
                public void run() {
                    while(true) {
                        System.out.println("thread " + j + ": " + automicInteger.addAndGet(1));
                        try {
                            TimeUnit.SECONDS.sleep(1);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }).start();
        }
    }
}
